#! /bin/bash
echo "" >succ.log
echo "" >fail.log
ips=$(cat /root/iplist)
while :; do
    for ip in $ips; do
        #echo "正在ping $ip,请稍等..."
        ping -c 2 -w 3 "$ip" &>/dev/null
        if [ $? -eq 0 ]; then
            #       echo "`date` 地址$ip是通的"
            echo "$(date) $ip is online--" >>/root/succ.log
        else
            #       echo "地址$ip是不通的"
            echo "$(date) $ip is offline--" >>/root/fail.log
        fi
    done
    #echo "已经检测完毕"
done
